package com.wanxi;

//需求：已知一个数组 arr = {19, 28, 37, 46, 50}; 用程序实现把数组中的元素值交换，
//交换后的数组 arr = {50, 46, 37, 28, 19}; 并在控制台输出交换后的数组元素。
public class ChangArray {
    public static void main(String[] args) {
        int[] array = {19, 28, 37, 46, 50};

        changeArray(array);

        runArray(array);
    }


    private static void runArray(int[] array) {
        for (int i = 0; i < array.length; i++) {
            System.out.print(array[i] + " ");

        }
    }

    private static void changeArray(int[] array) {
        for (int i = 0; i < array.length / 2; i++) {
            int temp = array[i];
            array[i] = array[array.length - 1 - i];
            array[array.length - 1 - i] = temp;
        }
    }
}
